package com.briup.facade.web.controller;

import com.briup.common.web.Message;
import com.briup.common.web.MessageUtil;
import com.briup.dataset.service.IEntityService;
import com.briup.logging.annotation.LoggingAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@LoggingAccess("数据集分类下实体")
@RestController
@Api(tags = "数据集分类下实体")
public class EntityController {

    @Autowired
    private IEntityService entityService;

    @PutMapping(value = "/entity/removeEntity")
    @LoggingAccess("移动图片到指定目录")
    @ApiOperation(value = "移动图片到指定目录",notes = "更换图片的分类")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classifyId", value = "要移动的分类id", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "entityIds",value = "图片id集合",paramType = "query",dataType = "int",required = true,allowMultiple = true)
    })
    public Message removeImage(@RequestParam("classifyId") Integer classifyId, @RequestParam("entityIds") List<Integer> entityIds) {

        entityService.removeImage(classifyId, entityIds);
        return MessageUtil.success();
    }

    @DeleteMapping(value = "/entity/delete")
    @LoggingAccess("删除图片")
    @ApiOperation(value = "删除图片", notes = "批量删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "图片id集合", paramType = "query", dataType = "int", required = true,allowMultiple = true)
    })
    public Message deleteClassifyById(@RequestParam("ids") List<Integer> ids) {

        entityService.deleteEntityById(ids);
        return MessageUtil.success();
    }
}
